﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="SettingsStoreTests.cs" company="XamlNinja">
//   2011 Richard Griffin and Ollie Riches
// </copyright>
// <summary>
//   Settings store unit tests - we follow BDD principles, http://dannorth.net/introducing-bdd/
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace WP7Contrib.Services.Tests
{
    using Logging;
    using Microsoft.Silverlight.Testing;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Settings;

    [TestClass]
    public class SettingsStoreTests : SilverlightTest
    {
        [TestMethod]
        public void ShouldWriteSetting()
        {
            // Given we can create settings store...
            var settings = new SettingsStore();

            // When we write the setting...
            settings.Write("The Question", "42");

            // Then we don't expect there to be any exceptions...
        }

        [TestMethod]
        public void ShouldReadSetting()
        {
            // Given we can create settings store...
            var settings = new SettingsStore(new NullLoggingService());

            // Given we can write the setting...
            settings.Write("The Question", "42");

            // When we reading the value from settings...
            var setting = string.Empty;
            var read = settings.TryToRead("The Question", out setting);

            // Then we expect have read the value...
            Assert.IsTrue(read);
            Assert.AreEqual(setting, "42");
        }
    }
}